/*
 *此javaCode由YMS-JDBC替换工具生成，原mapper位置com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper
 */
package com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.impl;

import com.yonyou.iuap.yms.api.IYmsJdbcApi;
import com.yonyou.iuap.yms.param.*;
import com.yonyou.iuap.yms.param.ResultSetProcessor;
import com.yonyou.iuap.yms.processor.*;
import com.yonyou.iuap.yms.replace.CollectionUtil;
import com.yonyou.ucf.mdf.app.isvdxq.firstpart.RFIDCodeDetail.entity.ReRFIDCode;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.entity.EpcEntity;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.entity.TaglistEntity;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.model.EpcBean;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.model.EpcEntityBean;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.model.EpcInParamBean;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TaglistMapperImpl {
    
    @Autowired
    private IYmsJdbcApi ymsJdbcApi;
    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.EditCoderfid
    
    public int EditCoderfid(List<String> strList, String modifier, String tenant_id, String location_id, String shelf_id) {
		if (strList == null || strList.size()==0) return 0;
		SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_coderfid set shelf_id=?, location_id=?, modifier=?, modify_time=now() where rfid_code in ");
		parameter.addParam(shelf_id);
		parameter.addParam(location_id);
		parameter.addParam(modifier);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectByIds
    
    public List<TaglistEntity> selectByIds(List<String> strList) {
		if (strList==null || strList.size()==0) return new ArrayList<>();
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from isv_taglist where `id` in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and dr=0; ");

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new TaglistEntity());
        return (List<TaglistEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.insert
    
    public int insert(TaglistEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "insert into isv_taglist (`id`, `name`,  `coderfid`, `status`,  `create_time`, `creator`,  `creatorname`,  `dr`, `ytenant_id`,`orgId`,  `version`, `opertime`,  `opername`, `operuserid`) values (?, ?,  ?, ?,  ?, ?,  ?,  ?, ?,?,  ?, ?,  ?, ?)\n";
        parameter.addParamWithType(record.getId(), Types.BIGINT);
		parameter.addParamWithType(record.getName(), Types.VARCHAR);
		parameter.addParamWithType(record.getCoderfid(), Types.VARCHAR);
		parameter.addParamWithType(record.getStatus(), Types.INTEGER);
		parameter.addParamWithType(record.getCreateTime(), Types.TIMESTAMP);
		parameter.addParamWithType(record.getCreator(), Types.VARCHAR);
		parameter.addParamWithType(record.getCreatorname(), Types.VARCHAR);
		parameter.addParamWithType(record.getDr(), Types.SMALLINT);
		parameter.addParamWithType(record.getYtenant_id(), Types.VARCHAR);
		parameter.addParamWithType(record.getOrgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getVersion(), Types.INTEGER);
		parameter.addParamWithType(record.getOpertime(), Types.TIMESTAMP);
		parameter.addParamWithType(record.getOpername(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperuserid(), Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEntityByTag
    
    public List<TaglistEntity> selectEntityByTag(String val, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from isv_taglist where name=? and ytenant_id=? and dr=0;\n";
        parameter.addParam(val);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new TaglistEntity());
        return (List<TaglistEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEpcinfoByTag
    
    public List<EpcEntity> selectEpcinfoByTag(String tag, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select a.*  from dxq_coderfid a  inner join isv_taglist b on a.rfid_code = b.coderfid   where b.name = ?  and a.ytenant_id=? and a.dr=0;\n";
        parameter.addParam(tag);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcEntity());
        return (List<EpcEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEpcEntityByEpcs
    
    public List<EpcEntity> selectEpcEntityByEpcs(List<String> strList, String tenant_id) {
		if (strList==null || strList.size()==0) return new ArrayList<>();
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from dxq_coderfid where rfid_code in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcEntity());
        return (List<EpcEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.updateByPrimaryKey
    
    public int updateByPrimaryKey(TaglistEntity record) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "update isv_taglist set `name` = ?, `coderfid` = ?, `status` = ?, `create_time` = ?, `creator` = ?, `creatorname` = ?, `pubts` = ?, `dr` = ?, `ytenant_id` = ?, `orgId` = ?, `version` = ?, `opertime` = ?, `opername` = ?, `operuserid` = ? where `id` = ?\n";
        parameter.addParamWithType(record.getName(), Types.VARCHAR);
		parameter.addParamWithType(record.getCoderfid(), Types.VARCHAR);
		parameter.addParamWithType(record.getStatus(), Types.INTEGER);
		parameter.addParamWithType(record.getCreateTime(), Types.TIMESTAMP);
		parameter.addParamWithType(record.getCreator(), Types.VARCHAR);
		parameter.addParamWithType(record.getCreatorname(), Types.VARCHAR);
		parameter.addParamWithType(record.getPubts(), Types.TIMESTAMP);
		parameter.addParamWithType(record.getDr(), Types.SMALLINT);
		parameter.addParamWithType(record.getYtenant_id(), Types.VARCHAR);
		parameter.addParamWithType(record.getOrgid(), Types.VARCHAR);
		parameter.addParamWithType(record.getVersion(), Types.INTEGER);
		parameter.addParamWithType(record.getOpertime(), Types.TIMESTAMP);
		parameter.addParamWithType(record.getOpername(), Types.VARCHAR);
		parameter.addParamWithType(record.getOperuserid(), Types.VARCHAR);
		parameter.addParamWithType(record.getId(), Types.BIGINT);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.getPickDetail
    
    public List<EpcBean> getPickDetail(String orderid, String pickbatchno, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  b.*,a.`id` as storerecordid,a.orderid,a.orderdetailid,a.batch_no,  w.code as warehouseCode,w.warehouseName,l.locationName,l.path,t.name as tag   FROM `dxq_storerecord` a inner JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id   left join dxqyy_warehouse w on b.warehouse_id=w.id  left join dxq_location l on b.location_id=l.id  left join isv_taglist t on b.rfid_code=t.coderfid  WHERE a.`orderid`=? and a.ytenant_id=? AND a.`dr`=0   and a.pickbatchno=?  and b.rfid_status =4 AND b.`dr`=0;\n";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);
		parameter.addParam(pickbatchno);

        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcBean());
        return (List<EpcBean>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.cleanCoderfid
    
    public int cleanCoderfid(List<String> strList, String modifier, String tenant_id) {
		if (strList == null || strList.size()==0) return 0;
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_coderfid set shelf_id='', location_id='', modifier=?, modify_time=now(), rfid_status=0 where id in ");
		parameter.addParam(modifier);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEpcEntityByKey
    
    public EpcEntity selectEpcEntityByKey(String key, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxq_coderfid where rfid_code =? and ytenant_id=? and dr=0 limit 1;\n";
        parameter.addParam(key);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanProcessor(new EpcEntity());
        return (EpcEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.deleteByEpc
    
    public int deleteByEpc(String epc, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "delete from isv_taglist where ytenant_id=? and `coderfid` = ?\n";
        parameter.addParam(tenant_id);
		parameter.addParamWithType(epc, Types.VARCHAR);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.getAllotDetail
    
    public List<ReRFIDCode> getAllotDetail(String orderid, String batchno_dxq, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "SELECT  b.`epc_tid`,b.`rfid_code`,b.`f_stock_count`,b.productDate,b.invalidDate,b.creator, b.product_id,b.product_sku_id,b.batchno,b.`location_id`,b.`id` as rfidcodeId,b.warehouse_id as warehouseid,  a.`id`,a.orderdetailid,a.orderid,a.batch_no,w.code as warehouseCode,w.warehouseName FROM `dxq_storerecord` a inner JOIN `dxq_coderfid` b ON a.`rfidcodeId`=b.id  left join dxqyy_warehouse w on w.id=b.warehouse_id  WHERE a.`orderid`=? and a.ytenant_id=? AND a.`dr`=0 and a.batchno_dxq=?  and b.rfid_status =5 and b.dr=0;";
        parameter.addParam(orderid);
		parameter.addParam(tenant_id);
		parameter.addParam(batchno_dxq);

        ResultSetProcessor processor = new AutoBeanListProcessor(new ReRFIDCode());
        return (List<ReRFIDCode>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectPage
    
    public List<TaglistEntity> selectPage(String tenantId, int m, int n) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from isv_taglist where `ytenant_id` = ? limit ?,?;\n";
        parameter.addParam(tenantId);
		parameter.addParam(m);
		parameter.addParam(n);

        ResultSetProcessor processor = new AutoBeanListProcessor(new TaglistEntity());
        return (List<TaglistEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEpcinfoTip
    
    public List<EpcBean> selectEpcinfoTip(List<String> proids, List<String> localtionIds, String batchno, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" SELECT b.*,CONCAT(b.product_id,\"|\",b.product_sku_id) productid, l.locationName,l.path,t.name as tag, w.code as warehouseCode,w.warehouseName ");
		sqlBuilder.append(" FROM `dxq_coderfid` b ");
		sqlBuilder.append(" left join dxqyy_warehouse w on b.warehouse_id=w.id");
		sqlBuilder.append(" left join dxq_location l on b.location_id=l.id ");
		sqlBuilder.append(" left join isv_taglist t on b.rfid_code=t.coderfid");
		sqlBuilder.append(" WHERE b.ytenant_id=? AND b.`dr`=0 ");
		parameter.addParam(tenant_id);
		if (batchno != null && !"".equals(batchno)) {
			sqlBuilder.append(" and b.batchno=? ");
			parameter.addParam(batchno);
		}
		if (localtionIds != null && localtionIds.size() > 0) {
			sqlBuilder.append(" and b.location_id in ");
			if (CollectionUtil.isNotEmpty(localtionIds)) {
				sqlBuilder.append(" ( ");
				String separator0 = " , ";
				for (int index = 0; index < localtionIds.size(); index++) {
					String id = localtionIds.get(index);
					sqlBuilder.append(" ? ");
					parameter.addParam(id);
					if (index < localtionIds.size() - 1) {
						sqlBuilder.append(separator0);
					}
				}
				sqlBuilder.append(" ) ");
			}
		}
		if (proids != null && proids.size() > 0) {
			sqlBuilder.append(" and b.productid in ");
			if (CollectionUtil.isNotEmpty(proids)) {
				sqlBuilder.append(" ( ");
				String separator1 = " , ";
				for (int index = 0; index < proids.size(); index++) {
					String id = proids.get(index);
					sqlBuilder.append(" ? ");
					parameter.addParam(id);
					if (index < proids.size() - 1) {
						sqlBuilder.append(separator1);
					}
				}
				sqlBuilder.append(" ) ");
			}
		}
		sqlBuilder.append(" order by b.invalidDate asc,b.id asc; ");

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcBean());
        return (List<EpcBean>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.editEpcList
    
    public int editEpcList(EpcInParamBean paramBean, List<String> strList, String modifier, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_coderfid set modifier=?, modify_time=now(), rfid_status=1, warehouse_id=?, warehouse_code=?, shelf_id=?, location_id=? where id in ");
		parameter.addParam(modifier);
		parameter.addParam(paramBean.getWarehouseID());
		parameter.addParam(paramBean.getWarehousecode());
		parameter.addParam(paramBean.getHuojiaid());
		parameter.addParam(paramBean.getLocationID());
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.editEpcListBatch

	/**
	 * @param modifier
	 * @param tenant_id
	 * @return
	 */
    public int editEpcListBatch(List<EpcInParamBean> strList, String modifier, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();

		if (CollectionUtil.isNotEmpty(strList)) {
			String separator0 = " ; ";
			for (int i = 0; i < strList.size(); i++) {
				EpcInParamBean item = strList.get(i);
				sqlBuilder.append(" update dxq_coderfid set modify_time=now(), rfid_status=1, modifier=?, warehouse_id=?, warehouse_code=?,shelf_id=?, location_id=?");
				sqlBuilder.append(" where id = ? and ytenant_id=? and dr=0 ");
				parameter.addParamWithType(modifier, Types.VARCHAR);
				parameter.addParamWithType(item.getWarehouseID(), Types.VARCHAR);
				parameter.addParamWithType(item.getWarehousecode(), Types.VARCHAR);
				parameter.addParamWithType(item.getHuojiaid(), Types.VARCHAR);
				parameter.addParamWithType(item.getLocationID(), Types.VARCHAR);
				parameter.addParamWithType(item.getId(), Types.VARCHAR);
				parameter.addParamWithType(tenant_id, Types.VARCHAR);
				if (i < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }
	public int editEpcListBatch(EpcInParamBean item, String modifier, String tenant_id) {
		SQLParameter parameter = new SQLParameter(true);
		StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_coderfid set modify_time=now(), rfid_status=1, modifier=?, warehouse_id=?, warehouse_code=?,shelf_id=?, location_id=?");
		sqlBuilder.append(" where id = ? and ytenant_id=? and dr=0 ");

		parameter.addParamWithType(modifier, Types.VARCHAR);
		parameter.addParamWithType(item.getWarehouseID(), Types.VARCHAR);
		parameter.addParamWithType(item.getWarehousecode(), Types.VARCHAR);
		parameter.addParamWithType(item.getHuojiaid(), Types.VARCHAR);
		parameter.addParamWithType(item.getLocationID(), Types.VARCHAR);
		parameter.addParamWithType(item.getId(), Types.VARCHAR);
		parameter.addParamWithType(tenant_id, Types.VARCHAR);

		String sql = sqlBuilder.toString();

		return ymsJdbcApi.update(sql, parameter);
	}

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.deleteByEpcKeys
    
    public int deleteByEpcKeys(List<String> strList, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" delete from isv_taglist where ytenant_id=? and `coderfid` in ( ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(strList)) {
			String separator0 = " , ";
			for (int i = 0; i < strList.size(); i++) {
				String item = strList.get(i);
				sqlBuilder.append(" ? ");
				parameter.addParamWithType(item, Types.VARCHAR);
				if (i < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
		sqlBuilder.append(" ) ");

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectById
    
    public TaglistEntity selectById(String id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from isv_taglist where `id`=? limit 1;\n";
        parameter.addParam(id);

        ResultSetProcessor processor = new AutoBeanProcessor(new TaglistEntity());
        return (TaglistEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.EditEntityByEpcKeys
    
    public int EditEntityByEpcKeys(List<String> strList, String tenant_id, String tag) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update isv_taglist set name = ? where ytenant_id=? and `coderfid` in ( ");
		parameter.addParam(tag);
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(strList)) {
			String separator0 = " , ";
			for (int i = 0; i < strList.size(); i++) {
				String item = strList.get(i);
				sqlBuilder.append(" ? ");
				parameter.addParamWithType(item, Types.VARCHAR);
				if (i < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
		sqlBuilder.append(" ) ");

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectAll
    
    public List<TaglistEntity> selectAll(String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from isv_taglist where  `dr`=0 and ytenant_id=?\n";
        parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new TaglistEntity());
        return (List<TaglistEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectInfoByTag
    
    public List<EpcEntity> selectInfoByTag(String tag, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select a.*   from dxq_coderfid a inner join isv_taglist b on a.rfid_code = b.coderfid   where b.name = ?  and a.ytenant_id=? and a.dr=0;\n";
        parameter.addParam(tag);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcEntity());
        return (List<EpcEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.deleteCoderfid
    
    public int deleteCoderfid(List<String> strList, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" delete from dxq_coderfid where id in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=?; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.getEpcinfo
    
    public List<EpcEntityBean> getEpcinfo(List<String> strList, String tenant_id) throws Exception {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" SELECT b.*,w.code as warehouseCode,w.warehouseName, l.locationName,l.path,t.name as tag FROM `dxq_coderfid` b left join dxqyy_warehouse w on b.warehouse_id=w.id left join dxq_location l on b.location_id=l.id left join isv_taglist t on b.rfid_code=t.coderfid WHERE b.id in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and b.ytenant_id=? AND b.`dr`=0 ");
		parameter.addParam(tenant_id);
		sqlBuilder.append(" and t.ytenant_id=? AND t.`dr`=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcEntityBean());
        return (List<EpcEntityBean>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectEpcEntityById
    
    public EpcEntity selectEpcEntityById(String id, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select * from dxq_coderfid where id =? and ytenant_id=? and dr=0 limit 1;\n";
        parameter.addParam(id);
		parameter.addParam(tenant_id);

        ResultSetProcessor processor = new AutoBeanProcessor(new EpcEntity());
        return (EpcEntity) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.deleteByPrimaryKeys
    
    public int deleteByPrimaryKeys(List<Long> ids, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" delete from isv_taglist where ytenant_id=? and `id` in ( ");
		parameter.addParam(tenant_id);
		if (CollectionUtil.isNotEmpty(ids)) {
			String separator0 = " , ";
			for (int i = 0; i < ids.size(); i++) {
				Long item = ids.get(i);
				sqlBuilder.append(" ? ");
				parameter.addParamWithType(item, Types.BIGINT);
				if (i < ids.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
		sqlBuilder.append(" ) ");

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectCount
    
    public int selectCount(Long id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "select count(1) from isv_taglist where `id`=? and dr=0;\n";
        parameter.addParam(id);

        ResultSetProcessor processor = new ColumnProcessor(int.class);
        return (int) ymsJdbcApi.queryForObject(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.insertBatch
    
    public int insertBatch(List<TaglistEntity> insertBatch) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" insert into isv_taglist (`id`, `name`, `coderfid`, `status`, `create_time`, `creator`, `creatorname`, `dr`, `ytenant_id`, `orgId`,`version`, `opertime`, `opername`, `operuserid`) values ");
		if (CollectionUtil.isNotEmpty(insertBatch)) {
			String separator0 = " , ";
			for (int i = 0; i < insertBatch.size(); i++) {
				TaglistEntity item = insertBatch.get(i);
				sqlBuilder.append(" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?) ");
				parameter.addParamWithType(item.getId(), Types.BIGINT);
				parameter.addParamWithType(item.getName(), Types.VARCHAR);
				parameter.addParamWithType(item.getCoderfid(), Types.VARCHAR);
				parameter.addParamWithType(item.getStatus(), Types.INTEGER);
				parameter.addParamWithType(item.getCreateTime(), Types.TIMESTAMP);
				parameter.addParamWithType(item.getCreator(), Types.VARCHAR);
				parameter.addParamWithType(item.getCreatorname(), Types.VARCHAR);
				parameter.addParamWithType(item.getDr(), Types.SMALLINT);
				parameter.addParamWithType(item.getYtenant_id(), Types.VARCHAR);
				parameter.addParamWithType(item.getOrgid(), Types.VARCHAR);
				parameter.addParamWithType(item.getVersion(), Types.INTEGER);
				parameter.addParamWithType(item.getOpertime(), Types.TIMESTAMP);
				parameter.addParamWithType(item.getOpername(), Types.VARCHAR);
				parameter.addParamWithType(item.getOperuserid(), Types.VARCHAR);
				if (i < insertBatch.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
		}
		sqlBuilder.append(" ON DUPLICATE KEY UPDATE name=VALUES(name),coderfid=VALUES(coderfid),status=VALUES(status) ,orgid=VALUES(orgid) ,opertime=VALUES(opertime),opername=VALUES(opername),operuserid=VALUES(operuserid) ");

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.deleteByPrimaryKey
    
    public int deleteByPrimaryKey(Long id, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        
        String sql = "delete from isv_taglist where ytenant_id=? and `id` = ?\n";
        parameter.addParam(tenant_id);
		parameter.addParamWithType(id, Types.BIGINT);

        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectByEpcs
    
    public List<TaglistEntity> selectByEpcs(List<String> strList, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from isv_taglist where coderfid in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new TaglistEntity());
        return (List<TaglistEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.editEpcListStatus
    
    public int editEpcListStatus(List<String> strList, String modifier, String tenant_id, Integer status) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" update dxq_coderfid set modifier=?, modify_time=now(), rfid_status=? where rfid_code in ");
		parameter.addParam(modifier);
		parameter.addParam(status);
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        
        return ymsJdbcApi.update(sql, parameter);
    }

    //com.yonyou.ucf.mdf.app.isvdxq.secondpart.mapper.TaglistMapper.selectInfoByEpcIds
    
    public List<EpcEntity> selectInfoByEpcIds(List<String> strList, String tenant_id) {
        SQLParameter parameter = new SQLParameter(true);
        StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append(" select * from dxq_coderfid where id in ");
		if (CollectionUtil.isNotEmpty(strList)) {
			sqlBuilder.append(" ( ");
			String separator0 = " , ";
			for (int index = 0; index < strList.size(); index++) {
				String item = strList.get(index);
				sqlBuilder.append(" ? ");
				parameter.addParam(item);
				if (index < strList.size() - 1) {
					sqlBuilder.append(separator0);
				}
			}
			sqlBuilder.append(" ) ");
		}
		sqlBuilder.append(" and ytenant_id=? and dr=0; ");
		parameter.addParam(tenant_id);

        
        String sql = sqlBuilder.toString();
        ResultSetProcessor processor = new AutoBeanListProcessor(new EpcEntity());
        return (List<EpcEntity>) ymsJdbcApi.queryForList(sql, parameter, processor);
    }

}
